<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Document</title>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.color.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
</head>
<body>

<!--通用顶部-->
<div id="ios-top-box">
    <div id="header" class="bar bar-nav">
    <div class="titlebar">
    <a href="javascript:appClose('userbuylist',api);"><i class="iconfont iconline-arrow-left"></i></a>
    <h1 class="title">抢购记录</h1>
    </div>
    </div>
</div>
<!--通用顶部结束-->

<section class="notBottom">
    <div class="scroller create_goods">
        <p class="notdata" style="text-align: center;display:none;">暂无记录</p>
		<div class="datalist"></div>
		<div class="loadings">
	    	<span class="clickLoad">点击加载</span>
	    	<span class="clickLoading">加载中请稍后...</span>
		</div>
    </div>
</section>

<script type="text/javascript" charset="utf-8">
apiready = function(){
$(function(){
	
	var userinfo;
    if(userinfo = getUserinfo()){
        var p = {totalPage:0};
		loadingData(1,userinfo);
		function loadingData(page,userinfo){
	        api.showProgress({title : '加载中',text : ''});
	    	GetJPData(config.url+'/app.php?act=userbuylist&uid='+userinfo['uid']+'&page='+page,{},function(data){
	    	    api.hideProgress();
	    	    if(data['status'] == 1){
					p.totalPage = data['totalPage'];
	    	        var html = "";
	    	        for(var i in data['data']){
	    	            html += '<ul class="listitem group_listitem">';
	    	            html += '<li style="border-bottom:1px solid #e4e4e4;">';
	    	            html += '<a href="javascript:openItem(\'userbuydetail\','+data['data'][i]['id']+',function(id){localData.set(\'orderid\',id);});">';
	                    html += '<img class="img lazy _loadimg'+page+'" data-original="'+config.upload_url+'/'+data['data'][i]['thumb']+'" width="25%"/></a>';
	                    html += '<div class="text">';
	                    html += '<p><a href="javascript:openItem(\'userbuydetail\','+data['data'][i]['id']+',function(id){localData.set(\'orderid\',id);});">'+data['data'][i]['shopname']+'</a></p>';
	                    html += '<p><span>购物期数：第'+data['data'][i]['shopqishu']+'期</span></p>';
	                    html += '<p><span>已参与：'+data['data'][i]['gonumber']+'次</span><a href="javascript:openItem(\'userbuydetail\','+data['data'][i]['id']+',function(id){localData.set(\'orderid\',id);});" class="common-btn view_detail">查看详情</a></p>';
	                    html += '</div></li></ul>';
	    	        }
		                $('.datalist').append(html);
		                $("img._loadimg"+page).lazyload({effect: "fadeIn"});
		            	if(page>1){
							$('.clickLoading').hide();
							$('.clickLoad').show();
						}
	    	    }else{
	    	        $('.notdata').show();
	    	    }
	    	});
		}
    	     
	var page = 1;
	$('.clickLoad').click(function(){
		var _this = $(this);
		page++;
		if(page > p.totalPage){
			_this.hide();
			$('.clickLoading').text('加载完毕').css('display','block');
			return false;
		}
		_this.hide();
		$('.clickLoading').css('display','block');

		loadingData(page,userinfo);
	});
			   
	}else{
	    $.PageDialog.fail('请登录用户');
	}
	
});
};
</script>
</body>
</html>